home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / basic / qbfaqr01.zip / A86TEST.DOC < prev    next >
Text File  |  1992-08-11  |  4KB  |  85 lines

  1. data segment para public 'data'
  2. first_variable dw ?             ;these are two word lenght variables
  3. which
  4. second_variable dw ?            ;is just the right len for an integer
  5.  
  6. code segment para public 'code
  7. addit:mov ax,0100            ;mov hex 100 into ax
  8. mov first_variable,ax        ;mov hex 100 from ax into first_variable
  9. mov ax,0150                  ;mov hex 150 into ax
  10. mov second_variable,ax       ;mov hex 150 from ax into second_variable
  11.  
  12.                              ;we now want to increment the value of
  13.                              ;first_varible by the amount found in
  14.                              ;second variable.  We can do this one of
  15.                              ;two ways:
  16. mov dx,0
  17. mov ax,first_variable
  18. add ax,second_variable       ;if we have an overflow condition we want
  19.                              ;to store the overflow in dx:
  20. if c add dx,1                ;this is unique to a86! it allows a one
  21.                              ;instruction jump
  22.                              ;we have now added the value of
  23. second_variable
  24.                              ;to the value of first_variable and the
  25.                              ;result is in ax, so:
  26. mov first_variable,ax        ;this transfers the total into
  27. first_variable
  28. mov second_variable,dx       ;this moves the overflow into
  29. second_variable
  30. retf                         ;far return to calling proceedure.  If any
  31.                              ;parameters passed, remember to clean up
  32.                              ;the stack: retf 2*number_of_parms
  33.  
  34. ;The second way would be as such:
  35.  
  36. incrementit:mov dx,0         ;sets dx to zero
  37. mov ax,first_variable        ;moves contents of first_variable into ax
  38. mov cx,second_variable       ;moves contents of second_variable into a
  39.                              ;counter register,cx
  40. L1:inc ax                    ;L1 is a local lable
  41. if c add dx,1                ;if operator is unique to A86 to perform
  42.                              ;a one instruction jump
  43. loop L1                      ;each time a loop is performed, cx is dec
  44.                              ;by one and will loop until cx=0
  45. mov first_variable,ax        ;as above, we store contents of ax into
  46.                              ;first_varaible
  47. mov second_varaible,dx       ;and the contents of dx into second_variable
  48. retf                         ;remember to clean up the stack!
  49.  
  50.  
  51. The only times you need asciiz strings are when you are dealing with
  52. file names, such as opening,closing, reading or writing to a file
  53. using file handles.  If you are printing a string to the screen, say
  54. using int 021 function 09, then you need your string to end in a
  55. dollar sign like this:
  56. sample_string db 'this string is to be printed$'
  57.  
  58. Int 021 function 09 will print to the screen:
  59.  
  60. this string is to be printed
  61.  
  62. the "$" will not be printed but is used by int 021 function 09 as the
  63. string terminator.
  64. Int 010 function 0a will let you print a string to the screen starting
  65. at the current cursor position.  You must tell this function the
  66. length of the string in cx.  Other then that, this string needs no
  67. termination code, such a chr$(0) or "$".  Note this is a bios call and
  68. will work on must compatables, but is not guaranteed to work on all.
  69. It is fairly fast and is easy to work with.
  70.  
  71. Things to watch for is ES and DS.  The extra segment and data segment.
  72. Most of my bugs that have given me headaches are these two
  73. registers!!!!  Moving strings from one location to another uses DS:SI
  74. for the sourse location and ES:DI for the destination location.
  75. Almost all string manipulation uses one or both of these combinations.
  76.  
  77. Well have fun with A86.  To me its greatest use is to make small, very
  78. fast subs for making librarys for use with QBX and QB.  It is fun to
  79. work with, but can be very, very frustrating at times especially when
  80. it does just what you tell it to do, and that is not what you really
  81. wanted it to do!
  82.  
  83. Seeya                        Larry Teghtmeyer
  84.  
  85.